package com.duobaoyu.dby.supply.biz.enums;

import cn.hutool.core.util.StrUtil;
import com.duobaoyu.dby.common.core.constant.StringPool;
import com.duobaoyu.dby.common.mybatis.enums.IBaseEnum;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;

import java.util.List;
import java.util.Objects;

/**
 * @author chenms
 * @date 2023/10/7 11:34 AM
 */
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum OrderTagEnum implements IBaseEnum<String, String>{
    ASYNC("async","异步订单"),
    SYNC("sync","同步订单"),
	ORDINARY_ORDER("ordinary_order","普通订单"),
	LARGE_ORDER("large_order","大额订单"),

    REPAIRING("repairing", "补单中");

    private final String val;

    private final String desc;

    /**
     * 是否异步订单
     */
    public static boolean isAsyncOrder(String orderTag) {
        List<String> tags = StrUtil.split(orderTag, StringPool.COMMA);
        return Objects.nonNull(tags) && tags.contains(ASYNC.val);
    }

    /**
     * 是否普通订单
     */

    public static boolean isOrdinaryOrder(String orderTag) {
        List<String> tags = StrUtil.split(orderTag, StringPool.COMMA);
        return Objects.nonNull(tags) && tags.contains(ORDINARY_ORDER.val);
    }

    /**
     * 是否大额订单
     */

    public static boolean isLargeAmountOrder(String orderTag) {
        List<String> tags = StrUtil.split(orderTag, StringPool.COMMA);
        return Objects.nonNull(tags) && tags.contains(LARGE_ORDER.val);
    }

    /**
     * 是否正在补单
     * @param orderTag
     * @return
     */
    public static boolean isRepairing(String orderTag) {
        List<String> tags = StrUtil.split(orderTag, StringPool.COMMA);
        return Objects.nonNull(tags) && tags.contains(REPAIRING.val);
    }

    @Override
    public String getValue() {
        return this.val;
    }


	@Override
	public String getDescribe(){
		return this.desc;
	}
}
